package com.lemon.controller;
import com.lemon.domain.PageResult;
import com.lemon.domain.Result;
import com.lemon.domain.StocktakingInfo;
import com.lemon.domain.dto.AddStocktakingDto;
import com.lemon.service.StocktakingInfoService;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 盘点信息记录表(stocktaking_info)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/stocktaking_info")
public class StocktakingInfoController {

    @Autowired
    private StocktakingInfoService stocktakingInfoService;

    @DeleteMapping("/{id}")
    public Result deleteStocktakingInfo(@PathVariable Integer id) {
        stocktakingInfoService.removeById(id);
        return Result.success();
    }


    @PutMapping
    public Result confirm(@RequestBody StocktakingInfo stocktakingInfo){
        stocktakingInfoService.confirm(stocktakingInfo);
        return Result.success();
    }


    @GetMapping
    public Result getPage(Integer page, Integer pageSize,String title,Integer category, Integer status){
        PageResult pageResult = stocktakingInfoService.getPage(page, pageSize, title,status,category);
        return Result.success(pageResult);
    }

    @PostMapping
    public Result add(@RequestBody List<AddStocktakingDto> addStocktakingDtos){
        stocktakingInfoService.add(addStocktakingDtos);
        return Result.success();
    }
}
